package com.qf.controller;

import com.qf.pojo.Bookclass;
import com.qf.service.BookclassService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class BookclassController {
    @Resource
    BookclassService bookclassService;
    @RequestMapping("/findAllBookclass")
    public List<Bookclass> findAllBookclass(){

        return bookclassService.findAll();
    }

    @RequestMapping(value = "/addBookclass",method = RequestMethod.POST)
    public int addBookclass(@RequestBody Bookclass bookclass){
        int add = bookclassService.add(bookclass);
        if (add>0){
            return 1;
        }else {
            return 0;
        }
    }
    @RequestMapping(value = "/updateBookclass",method = RequestMethod.POST)
    public int updateBookclass(@RequestBody Bookclass bookclass){
        int update = bookclassService.update(bookclass);
        if (update>0){
            return 1;
        }else {
            return 0;
        }
    }

    @RequestMapping("/deleteBookclass/{bcid}")
    public int deleteBookclass(@PathVariable("bcid")int bcid) {
        int delete = bookclassService.delete(bcid);
        if (delete>0){
            return 1;
        }else {
            return 0;
        }
    }

    @RequestMapping("/findBookclassByBcid/{bcid}")
    public Bookclass findBookclassByBcid(@PathVariable("bcid")int bcid){
        return bookclassService.findBookclassByBcid(bcid);
    }
}
